package com.dahua.appendix.version1;

/**
 * @author sunhongguang
 * @create 2022-01-05-22:48
 */
public class Dog {

    private String name;
    /**
     * 控制叫声的次数字段，默认值为3
     */
    private int shoutNum = 3;

    public Dog() {
        this.name = "无名";
    }

    public Dog(String name) {
        this.name = name;
    }

    public void setShoutNum(int shoutNum) {
        if (shoutNum <= 10) {
            this.shoutNum = shoutNum;
        } else {
            this.shoutNum = 10;
        }
    }

    public int getShoutNum() {
        return shoutNum;
    }

    public String shout() {
        String result = "";
        for (int i = 0; i < shoutNum; i++) {
            result += "汪 ";
        }
        return "我的名字叫" + name + " "+result;
    }

}
